/**
 * 
 */
package com.precisosoft.mathematize.client;

import com.google.web.bindery.event.shared.EventBus;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.proxy.PlaceManagerImpl;
import com.gwtplatform.mvp.client.proxy.PlaceRequest;
import com.gwtplatform.mvp.client.proxy.TokenFormatter;
import com.precisosoft.mathematize.client.gin.DefaultPlace;

/**
 * @author jewettdx
 *
 */
public class MathematizePlaceManager extends PlaceManagerImpl {

	  private final PlaceRequest defaultPlaceRequest;

	  @Inject
	  public MathematizePlaceManager(EventBus eventBus, TokenFormatter tokenFormatter,
	      @DefaultPlace String defaultNameToken) {
	    super(eventBus, tokenFormatter);

	    this.defaultPlaceRequest = new PlaceRequest(defaultNameToken);
	  }

	  //@Override
	  public void revealDefaultPlace() {
	    revealPlace(defaultPlaceRequest);
	  }

	  @Override
	  public void revealUnauthorizedPlace(String unauthorizedHistoryToken) {
	    PlaceRequest placeRequest = new PlaceRequest(NameTokens.signInPage);
	    placeRequest = placeRequest.with("redirect", unauthorizedHistoryToken);
	    revealPlace(placeRequest);
	  }

	  @Override
	  public void revealErrorPlace(String invalidHistoryToken) {
	    PlaceRequest placeRequest = new PlaceRequest(NameTokens.errorPage);
	    revealPlace(placeRequest);
	  }

}
